package com.atguigu.gulimall.product.comfig;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
//public class MyRedissonConfig {
//    @Bean
//   public RedissonClient redisson() throws IOException {
//        Config config = new Config();
//        config.useSingleServer().setAddress("redis://192.168.56.10:6379");
//        RedissonClient redissonClient = Redisson.create(config);
//        return redissonClient ;
//    }
//}
@Configuration
public class MyRedissonConfig {
    @Value("192.168.56.10")
    String host;
    @Value("6379")
    String port;
    @Bean
    RedissonClient redisson() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://"+host+":"+port);
        return Redisson.create(config);
    }
}
